package gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

/**
 * Erzeugt TerminPanels für die DayView
 * 
 * @author Michi
 * 
 */
public class TerminPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5584360608548113475L;
	// E=Event, G=Geburtstag, T=Task
	private String panelType;
	private Color eventColor = Color.GRAY;
	private Color birthdayColor = Color.ORANGE;
	private Color taskColor = Color.RED;
	private JTextField eventNameTextField;
	private JPanel eventNamePanel;
	private JPanel eventDatePanel;
	private JTextField eventDateStartTextField;
	private JTextField eventDateEndTextField;
	private JTextField eventBeginnTextField;
	private JTextField eventEndeTextField;
	private String ort;
	private String calendar;
	private String teilnehmer;
	private String notiz;
	private Object terminArt;
	private JLabel label;

	public String getOrt() {
		return ort;
	}

	public void setOrt(String ort) {
		this.ort = ort;
	}

	public String getCalendar() {
		return calendar;
	}

	public void setCalendar(String calendar) {
		this.calendar = calendar;
	}

	public String getTeilnehmer() {
		return teilnehmer;
	}

	public void setTeilnehmer(String teilnehmer) {
		this.teilnehmer = teilnehmer;
	}

	/**
	 * Create the panel.
	 */
	public TerminPanel() {
		setBorder(BorderFactory.createLineBorder(Color.black, 1));
		setSize(new Dimension(350, 100));
		setMinimumSize(new Dimension(350, 50));
		setMaximumSize(new Dimension(350, 100));
		setPreferredSize(new Dimension(350, 70));
		setLayout(new GridLayout(0, 1, 0, 0));

		eventNamePanel = new JPanel();
		eventNamePanel.setBackground(new Color(245, 245, 220));
		eventNamePanel.setSize(new Dimension(350, 50));
		eventNamePanel.setMaximumSize(new Dimension(350, 50));
		eventNamePanel.setMinimumSize(new Dimension(350, 30));
		eventNamePanel.setPreferredSize(new Dimension(350, 30));
		add(eventNamePanel);

		eventNameTextField = new JTextField();
		eventNameTextField.setBorder(null);
		eventNameTextField.setFont(new Font("Lucida Grande", Font.BOLD, 13));
		eventNameTextField.setDisabledTextColor(Color.BLACK);
		eventNameTextField.setEnabled(false);
		eventNameTextField.setEditable(false);
		eventNameTextField.setSize(new Dimension(340, 40));
		eventNameTextField.setMaximumSize(new Dimension(340, 40));
		eventNameTextField.setMinimumSize(new Dimension(340, 25));
		eventNameTextField.setPreferredSize(new Dimension(340, 25));
		eventNamePanel.add(eventNameTextField);
		eventNameTextField.setColumns(26);

		eventDatePanel = new JPanel();
		eventDatePanel.setBackground(new Color(245, 245, 220));
		eventDatePanel.setMinimumSize(new Dimension(10, 20));
		eventDatePanel.setPreferredSize(new Dimension(10, 20));
		add(eventDatePanel);
		GridBagLayout gbl_eventDatePanel = new GridBagLayout();
		gbl_eventDatePanel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0 };
		gbl_eventDatePanel.rowHeights = new int[] { 0, 0 };
		gbl_eventDatePanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0,
				0.0, Double.MIN_VALUE };
		gbl_eventDatePanel.rowWeights = new double[] { 1.0, Double.MIN_VALUE };
		eventDatePanel.setLayout(gbl_eventDatePanel);

		eventBeginnTextField = new JTextField();
		GridBagConstraints gbc_eventBeginnTextField = new GridBagConstraints();
		gbc_eventBeginnTextField.insets = new Insets(0, 0, 0, 5);
		gbc_eventBeginnTextField.gridx = 0;
		gbc_eventBeginnTextField.gridy = 0;
		eventDatePanel.add(eventBeginnTextField, gbc_eventBeginnTextField);
		eventBeginnTextField.setDisabledTextColor(Color.BLACK);
		eventBeginnTextField.setEnabled(false);
		eventBeginnTextField.setEditable(false);
		eventBeginnTextField.setFont(new Font("Lucida Grande", Font.PLAIN, 11));
		eventBeginnTextField.setMaximumSize(new Dimension(165, 20));
		eventBeginnTextField.setMinimumSize(new Dimension(50, 20));
		eventBeginnTextField.setSize(new Dimension(165, 20));
		eventBeginnTextField.setPreferredSize(new Dimension(50, 20));
		// eventBeginnTextField.setBorder(null);
		eventBeginnTextField.setHorizontalAlignment(SwingConstants.CENTER);
		eventBeginnTextField.setText("Beginn");
		eventBeginnTextField.setColumns(10);

		eventDateStartTextField = new JTextField();
		GridBagConstraints gbc_eventDateStartTextField = new GridBagConstraints();
		gbc_eventDateStartTextField.insets = new Insets(0, 0, 0, 5);
		gbc_eventDateStartTextField.gridx = 1;
		gbc_eventDateStartTextField.gridy = 0;
		eventDatePanel
				.add(eventDateStartTextField, gbc_eventDateStartTextField);
		eventDateStartTextField.setFont(new Font("Lucida Grande", Font.PLAIN,
				11));
		// eventDateStartTextField.setBorder(null);
		eventDateStartTextField.setDisabledTextColor(Color.BLACK);
		eventDateStartTextField.setHorizontalAlignment(SwingConstants.CENTER);
		eventDateStartTextField.setEnabled(false);
		eventDateStartTextField.setEditable(false);
		eventDateStartTextField.setSize(new Dimension(165, 20));
		eventDateStartTextField.setPreferredSize(new Dimension(50, 20));
		eventDateStartTextField.setMinimumSize(new Dimension(111, 20));
		eventDateStartTextField.setMaximumSize(new Dimension(165, 20));
		eventDateStartTextField.setColumns(10);

		label = new JLabel("-");
		GridBagConstraints gbc_label = new GridBagConstraints();
		gbc_label.insets = new Insets(0, 0, 0, 5);
		gbc_label.anchor = GridBagConstraints.EAST;
		gbc_label.gridx = 2;
		gbc_label.gridy = 0;
		eventDatePanel.add(label, gbc_label);

		eventDateEndTextField = new JTextField();
		GridBagConstraints gbc_eventDateEndTextField = new GridBagConstraints();
		gbc_eventDateEndTextField.insets = new Insets(0, 0, 0, 5);
		gbc_eventDateEndTextField.gridx = 3;
		gbc_eventDateEndTextField.gridy = 0;
		eventDatePanel.add(eventDateEndTextField, gbc_eventDateEndTextField);
		eventDateEndTextField
				.setFont(new Font("Lucida Grande", Font.PLAIN, 11));
		// eventDateEndTextField.setBorder(null);
		eventDateEndTextField.setDisabledTextColor(Color.BLACK);
		eventDateEndTextField.setHorizontalAlignment(SwingConstants.CENTER);
		eventDateEndTextField.setEnabled(false);
		eventDateEndTextField.setEditable(false);
		eventDateEndTextField.setSize(new Dimension(165, 20));
		eventDateEndTextField.setPreferredSize(new Dimension(165, 20));
		eventDateEndTextField.setMinimumSize(new Dimension(111, 20));
		eventDateEndTextField.setMaximumSize(new Dimension(165, 20));
		eventDateEndTextField.setColumns(10);

		eventEndeTextField = new JTextField();
		GridBagConstraints gbc_eventEndeTextField = new GridBagConstraints();
		gbc_eventEndeTextField.gridx = 4;
		gbc_eventEndeTextField.gridy = 0;
		eventDatePanel.add(eventEndeTextField, gbc_eventEndeTextField);
		eventEndeTextField.setEnabled(false);
		eventEndeTextField.setEditable(false);
		eventEndeTextField.setDisabledTextColor(Color.BLACK);
		eventEndeTextField.setSize(new Dimension(165, 20));
		eventEndeTextField.setPreferredSize(new Dimension(165, 20));
		eventEndeTextField.setMinimumSize(new Dimension(50, 20));
		eventEndeTextField.setMaximumSize(new Dimension(165, 20));
		eventEndeTextField.setFont(new Font("Lucida Grande", Font.PLAIN, 11));
		// eventEndeTextField.setBorder(null);
		eventEndeTextField.setText("Ende");
		eventEndeTextField.setHorizontalAlignment(SwingConstants.CENTER);
		eventEndeTextField.setColumns(10);

	}

	public void changeColor(Color color) {

		eventNamePanel.setBackground(color);
		eventDatePanel.setBackground(color);
		// eventDatePanelStart.setBackground(color);
		// eventDatePanelEnd.setBackground(color);

		// TODO
		eventBeginnTextField.setBackground(Color.white);
		eventEndeTextField.setBackground(Color.white);
		eventDateStartTextField.setBackground(Color.white);
		eventNameTextField.setBackground(Color.white);
		eventDateEndTextField.setBackground(Color.white);
	}

	// Setter & Getter
	public String getPanelType() {
		return panelType;
	}

	public void setPanelType(String panelType) {
		this.panelType = panelType;
	}

	public Color getEventColor() {
		return eventColor;
	}

	public void setEventColor(Color eventColor) {
		this.eventColor = eventColor;
	}

	public Color getBirthdayColor() {
		return birthdayColor;
	}

	public void setBirthdayColor(Color birthdayColor) {
		this.birthdayColor = birthdayColor;
	}

	public Color getTaskColor() {
		return taskColor;
	}

	public void setTaskColor(Color taskColor) {
		this.taskColor = taskColor;
	}

	public JTextField getEventNameTextField() {
		return eventNameTextField;
	}

	public void setEventNameTextField(JTextField eventNameTextField) {
		this.eventNameTextField = eventNameTextField;
	}

	public JPanel getEventNamePanel() {
		return eventNamePanel;
	}

	public void setEventNamePanel(JPanel eventNamePanel) {
		this.eventNamePanel = eventNamePanel;
	}

	public JPanel getEventDatePanel() {
		return eventDatePanel;
	}

	public void setEventDatePanel(JPanel eventDatePanel) {
		this.eventDatePanel = eventDatePanel;
	}

	public JTextField getEventDateStartTextField() {
		return eventDateStartTextField;
	}

	public void setEventDateStartTextField(JTextField eventDateStartTextField) {
		this.eventDateStartTextField = eventDateStartTextField;
	}

	public JTextField getEventBeginnTextField() {
		return eventBeginnTextField;
	}

	public void setEventBeginnTextField(JTextField eventBeginnTextField) {
		this.eventBeginnTextField = eventBeginnTextField;
	}

	public JTextField getEventEndeTextField() {
		return eventEndeTextField;
	}

	public void setEventEndeTextField(JTextField eventEndeTextField) {
		this.eventEndeTextField = eventEndeTextField;
	}

	public JTextField getEventDateEndTextField() {
		return eventDateEndTextField;
	}

	public void setEventDateEndTextField(JTextField eventDateEndTextField) {
		this.eventDateEndTextField = eventDateEndTextField;
	}

	public String getNotiz() {
		return notiz;
	}

	public void setNotiz(String notiz) {
		this.notiz = notiz;
	}

	public Object getTerminArt() {
		return terminArt;
	}

	public void setTerminArt(Object terminArt) {
		this.terminArt = terminArt;
	}

}
